import { createStore } from 'vuex'
import { Toast } from "vant";

export default createStore({
  state() {
    return {
      userName: "子君",
      userAddr:'',
      hash:'',
      lang:'',
      token:'',
	  city:'',
      head:'',
      loadding:0,
	  uuid:'',
      Messages:[],
      homeBase:[],
    };
  },
  mutations:{
    SetUserAddr(state, userAddr) {
      state.userAddr = userAddr
    }, 
    SetHash(state,val) {
      state.hash = val
    }, 
	SetCity(state,val) {
	  state.city = val
	}, 
    SetToken(state, token) {
      state.token = token
    }, 
    SetLoadding(state, loadding) {
      state.loadding = loadding
    },
  },
  actions:{
   setLoadding(context,) {
    var lang = localStorage.getItem('lang') || 'en'   
    Toast.loading({ message: lang == 'en'?'Loadding':'加载中...', forbidClick: true, overlay:true, duration:0, });
    context.commit('SetLoadding',0)
   },
   cancelLoadding(context) {
    var lang = localStorage.getItem('lang') || 'en'  
    Toast.loading({ message: lang == 'en'?'Loadding':'加载中...', forbidClick: true, overlay:true, duration:100, });
    context.commit('SetLoadding',100)
   },
 }
});